﻿using System;
using Teigha.Core;

namespace OdaOperation.Core.Simplifier
{
    internal class SimpliferVectorizeDevice : OdGsBaseVectorizeDevice
    {
        private OdGiGeometrySimplifier m_geometrySimplifier;

        private SimplifierVectorizeView m_view;

        private SimplifierVectorizer m_vectorize;

        public SimpliferVectorizeDevice()
        {
            uint[] lightPalette = AllPalettes.getLightPalette();
            this.setBackgroundColor(lightPalette[0]);
            this.setLogicalPalette(lightPalette, 256);
            base.setTransientRenderType(OdGsModel.RenderType.kDirect);
        }

        internal void SetGeometrySimplifier(OdGiGeometrySimplifier geometry)
        {
            this.m_geometrySimplifier = geometry;
        }

        internal void SetView(SimplifierVectorizeView view, SimplifierVectorizer vectorizer)
        {
            this.m_view = view;
            this.m_vectorize = vectorizer;
            this.m_view.SetDevice(this);
            this.m_vectorize.SetDevice(this);
        }

        public override OdGsView createView(OdGsClientViewInfo pInfo, bool bEnableLayerVisibilityPerView)
        {
            this.m_vectorize.SetView(this.m_view);
            this.m_view.init(this, pInfo, bEnableLayerVisibilityPerView);
            this.m_vectorize.SetGeometrySimplifier(this.m_geometrySimplifier);
            return this.m_vectorize.gsView();
        }
    }
}
